﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace Microsoft.Popfly.GameCreator.GameEngine.Events
{
    public class LoadEventChecker : IEventChecker
    {
        private Game m_game;
        private BehaviorOwner m_owner;
        private EventListener m_thisListener;

        public LoadEventChecker(Game game, BehaviorOwner owner, EventListener thisListener)
        {
            m_game = game;
            m_owner = owner;
            m_thisListener = thisListener;
        }

        #region IEventChecker Members

        public bool FireThisFrame(double elapsedTimeInSeconds, out BehaviorOwner sender, out PGCEventArgs args)
        {
            bool retVal = false;
            if (m_owner.FinishedFirstUpdate == false)
            {
                sender = m_owner;
                args = null;
                retVal = true;
            }
            else
            {
                sender = null;
                args = null;
                retVal = false;
            }
            m_owner.RemoveBehavior(m_thisListener);

            return retVal;
        }

        public bool IsOfEventType(string eventType)
        {
            return eventType == "Load" || eventType == "";
        }

        #endregion
    }
}
